home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 January / macformat46.iso / Shareware Plus / Developers / LogoMation / LogoMation 1.1.3 ƒ / Examples / MoveUpDown / MoveUpDown
Encoding:
Text File  |  1996-10-24  |  1.9 KB  |  90 lines  |  [UVtx/UVtl]

  1. // This program demonstrates animating a picture using
  2. // the Curve command.  While the picture is moving, the
  3. // program changes the 'move' parameter, to alternate
  4. // between moving above and under the background.
  5.  
  6. Init()
  7.  
  8. DefPicture()
  9.  
  10. DrawRectangles()
  11.  
  12. PrepareToMove()
  13.  
  14. Curve Fx(t), 50*sin(t*(360/200))+40, t, -width()/2-30, width()/2+20
  15.  
  16. ////////////////////////////////////////
  17.  
  18. /////////////
  19. Function Init()
  20.     above=0
  21.     last_flip = 0
  22.  
  23. ////////////////////
  24. Function DefPicture()
  25.     Picture "MoveIt"
  26.         Fill 1,30000,40000,50000
  27.             Repeat 2
  28.                 Forward 30
  29.                 Right 45
  30.                 Forward 10
  31.                 Right 90
  32.                 Forward 10
  33.                 Right 45
  34.  
  35.  
  36. /////////////////////////
  37. Function DrawRectangles(x)
  38.     Up
  39.     Goto -width()/2, -55,0
  40.     Down
  41.     Fill 1,64926,65535,49999
  42.         Forward width()
  43.         Goto width()/2, -height()/2, 180
  44.         Forward width()
  45.     Repeat x,-width()/2+20, width()/2-20,100
  46.         Rect(x)
  47.  
  48. ///////////////
  49. Function Rect(X)
  50.     Up
  51.     w = random(5)+5
  52.     Goto X-w,-100-last_flip*20,90
  53.     last_flip = 1 - last_flip
  54.     Down
  55.     Repeat 2
  56.         Fill 1+int(random(2)),random(60000),random(60000), random(60000)
  57.             Forward 200
  58.             Right 90
  59.             Forward 2*w
  60.             Right 90
  61.     x1 = x()
  62.     y1 = y()
  63.     Fill 1,0,0,0
  64.         Goto x1+40,y1-20,0
  65.         Forward 2*w
  66.         Goto x1+2*w,y1,0
  67.  
  68.             
  69. ///////////////////////////////////////            
  70. Function PrepareToMove()
  71.     Up
  72.     Pen picture="MoveIt",speed=40
  73.     Goto -width()/2-50,0,0
  74.     Down
  75.     last_flip = 0
  76.  
  77. ////////////
  78. Function Fx(X)
  79.     If last_flip = 0  // first time thru
  80.         last_flip = X
  81.         Return X
  82.     dx = X - last_flip
  83.     If (dx > 100)
  84.         last_flip = X
  85.         If above
  86.             Pen move="above"
  87.         Else
  88.             Pen move="below"
  89.         above = 1-above
  90.     Return X